package com.company.最大匹配;

import java.util.Scanner;

public class HJ28匈牙利 {
    public static boolean isPrime1(int x) {
        if(x == 1)return false;
        for (int i = 2; i <= Math.sqrt(x); i++)
            if (x % i == 0)
                return false;
        return true;
    }
    public static int[] a1;
    public static int[] a2;
    //public static int[] p1;
    public static int[] p2;
    public static boolean change(int i,boolean[] v){
        if(i == 0)return true;
        for(int j = 1;j<p2.length;j++){
            if(isPrime1(a1[i]+a2[j])&&!v[j]){
                v[j]=true;
                if(change(p2[j],v)){
                    //p1[i] = j;
                    p2[j] = i;
                    return true;
                }
            }
        }
        return false;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(),n1=1,n2=1;
        a1 = new int[n+1];
        a2 = new int[n+1];
        for(int i = 0;i<n;i++){
            int x = in.nextInt();
            if(x%2==1)
                a1[n1++]=x;
            else
                a2[n2++]=x;
        }
        //p1 = new int[n1];
        p2 = new int[n2];
        int ans = 0;
        for(int i = 1;i<n1;i++){
            if(change(i,new boolean[n2]))
                ans++;
        }
        System.out.print(ans);
    }
}
